package echat.future.cn.echat.my.adapter;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import echat.future.cn.echat.R;
import echat.future.cn.echat.my.bean.WithdrawBean;

public class WithdrawAdapter extends BaseMultiItemQuickAdapter<WithdrawBean,BaseViewHolder> {
    /**
     * Same as QuickAdapter#QuickAdapter(Context,int) but with
     * some initialization data.
     *
     * @param data A new list is created out of this one to avoid mutable list
     */
    public WithdrawAdapter(List<WithdrawBean> data) {
        super(data);
        addItemType(WithdrawBean.TYPE_NONE, R.layout.item_withdraw_empey);
        addItemType(WithdrawBean.TYPE_DATA, R.layout.item_withdraw_data);
        addItemType(WithdrawBean.TYPE_MONTH, R.layout.item_withdraw_month);
        addItemType(WithdrawBean.TYPE_TITLE, R.layout.item_withdraw_title);
    }


    private SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy.MM.dd");
    @Override
    protected void convert(BaseViewHolder helper, WithdrawBean item) {
        if(item.getItemType() == WithdrawBean.TYPE_DATA){
            helper.setText(R.id.money,item.getE_money().toString()).setText(R.id.time,simpleDateFormat.format(new Date(item.getCreate_time()*1000)));
        }else if(item.getItemType() == WithdrawBean.TYPE_MONTH){
            helper.setText(R.id.month,item.getMonth());
        }
    }
}
